package yb.ecp.fast.infra.service;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import yb.ecp.fast.infra.algorithm.SnowflakeIdWorker;

/**
 * Created by john on 2017/10/26.
 */
@Service
public class GuidService {
    @Value("${fast.guid.worker-id}")
    private int workerId;
    @Value("${fast.guid.datacenter-id}")
    private int datacenterId;

    private final SnowflakeIdWorker snowflakeIdWorker =
            new SnowflakeIdWorker(workerId, datacenterId);



    public long nextId(){
        return snowflakeIdWorker.nextId();
    }

}
